home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / WANDR330.ZIP / SRC / Display.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-01  |  5.4 KB  |  238 lines

  1. #include "wand_head.h"
  2. #include <curses.h>
  3.  
  4. extern int debug_disp;
  5. extern int edit_mode;
  6. extern char screen_name[61];
  7. extern char *edit_memory, *memory_end;
  8. extern WINDOW *win,*displaywin,*mapwin,*infowin;
  9. extern WINDOW *messagewin;
  10. extern int pause2;
  11. extern int pause1;
  12.  
  13. void draw_object(y,x,glyph)
  14. int x,y;
  15. char glyph;
  16. {
  17.     wmove(win,y,x);
  18.     waddch(win,glyph);
  19. }
  20.  
  21. void map(row_ptr)
  22. char (*row_ptr)[ROWLEN+1];
  23. {
  24.     int  x, y;
  25.     char ch;
  26.  
  27.     draw_object(0,0,'+');
  28.  
  29.     for (x = 0; x < ROWLEN; x++)
  30.     waddch(win,'-');
  31.    waddch(win,'+');
  32.  
  33.     for (y = 0; y < NOOFROWS; y++) {
  34.       draw_object(y+1,0,'|');
  35.  
  36.     
  37.  
  38.     for (x = 0; x < ROWLEN; x++) {
  39.         ch = (*row_ptr)[x];
  40.         if (ch == '@')
  41.         {
  42.         wattron(win,A_BOLD);
  43.         waddch(win,ch);
  44.         wattroff(win,A_BOLD);
  45.         continue;
  46.         }
  47.         if (!debug_disp) {
  48.         if ((ch == 'M') || (ch == 'S'))
  49.             ch = ' ';
  50.         waddch(win,ch);
  51.         } else if (ch != '\0')
  52.         waddch(win,ch);
  53.         else
  54.         waddch(win,'"');
  55.     }
  56.     waddch(win,'|');
  57.     row_ptr++;
  58.     }
  59.     draw_object(y+1,0,'+');
  60.     for (x = 0; x < ROWLEN; x++)
  61.     waddch(win,'-');
  62.     waddch(win,'+');
  63.     wrefresh(win);
  64.     if (!debug_disp) {
  65.     wmove(messagewin,0,0);
  66.     waddstr(messagewin,"Press any key to return to the game.");
  67.     wrefresh(messagewin);
  68.     wgetch(messagewin);
  69.     wmove(messagewin,0,0);
  70.     waddstr(messagewin,"                                    ");
  71.     wrefresh(messagewin);
  72.     for (y = 0; y <= (NOOFROWS+1); y++) {
  73.         wmove(win,y,0);
  74.         for (x = 0; x <= (ROWLEN+2); x++)
  75.         waddch(win,' ');
  76.     }
  77.     } 
  78. }
  79.  
  80. void display(cx, cy, row_ptr)
  81. char (*row_ptr)[ROWLEN+1];
  82. int  cx, cy;
  83. {
  84.     static int init=0;
  85.     int  x, y = 0,
  86.      x_coord, y_coord;
  87.     char ch;
  88.  
  89.     while (y < (cy-3)) {
  90.     y++;
  91.     row_ptr++;
  92.     }
  93.     wmove(win,0,0);
  94.     waddstr(win,"+---------------------------------+");
  95.     wmove(win,15,0);
  96.     waddstr(win,"+---------------------------------+");
  97.     wrefresh(win);
  98.     for (y = (cy-3); y <= (cy+3); y++) {
  99.     y_coord = (y+3-cy)*2;
  100.     if ((y < 0) || (y >= NOOFROWS)) {
  101.         wmove(win,y_coord+1,0);
  102.         waddstr(win,"|#################################|");
  103.         wmove(win,y_coord+2,0);
  104.         waddstr(win,"|#################################|");
  105.     } else {
  106.         wmove(win,y_coord+1,0);
  107.         waddch(win,'|');
  108.         wmove(win,y_coord+1,34);
  109.         waddch(win,'|');
  110.         wmove(win,y_coord+2,0);
  111.         waddch(win,'|');
  112.         wmove(win,y_coord+2,34);
  113.         waddch(win,'|');
  114.         for (x = (cx-5); x <= (cx+5); x++) {
  115.         x_coord = (x+5-cx)*3;
  116.         if ((x < 0) || (x > ROWLEN-1))
  117.             draw_symbol(x_coord,y_coord,'#');
  118.         else {
  119.             ch = (*row_ptr)[x];
  120.             draw_symbol(x_coord,y_coord,ch);
  121.         }
  122.         }
  123.         row_ptr++;
  124.     }    /* end if */
  125.     }    /* end y loop */
  126.     wmove(win,16,0);
  127.     wrefresh(win);
  128.  
  129.     if(init == 0)
  130.     {
  131.     init = 1;
  132.     wmove(messagewin,0,0);
  133.     waddstr(messagewin,"Press ? for help. Press # for map mode.");
  134.     wrefresh(messagewin);
  135.     }
  136. }
  137.  
  138. void redraw_screen(bell, maxmoves, num, score, nf, diamonds, mx, sx, sy, frow)
  139. int *bell, maxmoves, num, nf, diamonds, mx, sx, sy;
  140. long score;
  141. char (*frow)[ROWLEN+1];
  142. {
  143. char buffer[50];
  144.  
  145.     wclear(infowin);
  146.     if(!edit_mode)
  147.       {
  148.       sprintf(buffer,"screen %d",num);
  149.       wmove(infowin,0,0);
  150.       waddstr(infowin,buffer);
  151.       }
  152.     wmove(infowin,1,0);
  153.     if ((screen_name[0] == '#') || (screen_name[0] == '\0'))
  154.     waddstr(infowin,"no name                          ");
  155.     else
  156.     waddstr(infowin,screen_name);
  157.     sprintf(buffer,"score = %d ",score);
  158.     wmove(infowin,2,0);
  159.     waddstr(infowin,buffer);
  160.     sprintf(buffer,"diamonds = %d/%d   ",nf,diamonds);
  161.     wmove(infowin,3,0);
  162.     waddstr(infowin,buffer);
  163.     wmove(infowin,4,0);
  164.     if (maxmoves != -1)
  165.        sprintf(buffer,"max moves = %d",maxmoves);
  166.     else
  167.        sprintf(buffer,"max moves = no limit");
  168.     waddstr(infowin,buffer);
  169.     wmove(infowin,5,0);
  170.     if(*bell)
  171.      waddstr(infowin,"bell on");
  172.     else 
  173.      waddstr(infowin,"bell off");
  174.  
  175. /*    if (edit_memory)  { */
  176.     wmove(infowin,7,0);
  177.     waddstr(infowin,"MEMORY: ( Start, ) End,");
  178.     wmove(infowin,8,0);
  179.     waddstr(infowin,"* Play, & Extend.");
  180.     wmove(infowin,9,0);
  181.     waddstr(infowin,"- Chkpt, + Cont.");
  182.     wmove(infowin,10,0);
  183.     if (memory_end == edit_memory)
  184.         waddstr(infowin,"--Empty--");
  185.     else
  186.         waddstr(infowin,"-Occupied-");
  187.         wmove(infowin,11,0);
  188.         waddstr(infowin,"> Speed up < Slow down ");
  189.         wmove(infowin,12,0);
  190.         sprintf(buffer,"Play pause = %d",pause2);
  191.         waddstr(infowin,buffer);
  192.     sprintf(buffer,"Animation delay = %d ",pause1);
  193.         wmove(infowin,14,0);
  194.         waddstr(infowin,buffer);
  195.  
  196.  
  197.     wrefresh(infowin);
  198.  
  199.     if (!debug_disp)
  200.         {
  201.         win=displaywin;
  202.     display(sx,sy,frow);
  203.         }
  204.     else
  205.         {
  206.         win=mapwin; 
  207.     map(frow);
  208.         }
  209.  
  210. }
  211.  
  212. int inform_me(s, qable)
  213. char *s;
  214. int qable;
  215. {
  216.     int retval = 0;
  217.  
  218.     wmove(messagewin,0,0);
  219. #ifdef TVI
  220.     waddstr(messagewin,TVI);
  221. #endif
  222.     wstandout(messagewin);
  223.     waddstr(messagewin,s);
  224. #ifdef NOTVI
  225.     waddstr(messagewin,NOTVI);
  226. #endif
  227.     wstandend(messagewin);
  228.     waddstr(messagewin," <MORE>");
  229.     if (qable)
  230.     waddstr(messagewin," (q stops)");
  231.     wrefresh(messagewin);
  232.     if (wgetch(messagewin) == 'q')
  233.     retval = 1;
  234.     wmove(messagewin,0,0); waddstr(messagewin,"                                                         ");
  235.     wrefresh(messagewin);
  236.     return (retval);
  237. }
  238.